package cn.snorlaxzjt.LBSserver.filter;


import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

public class MyFilter implements Filter {

    private Map<Long,Long> blackList = new HashMap<>();

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {


    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
            throws IOException, ServletException {
        HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
        String Auth = httpServletRequest.getHeader("Authorization");
        Context context = Context.genContext(Auth);
        if(blackList.get(context.getUid())!=null && blackList.get(context.getUid()).equals(context.getDeviceId())){
            /*
            redis remove
            mysql remove
             */
        }
    }

    @Override
    public void destroy() {

    }
}
